<?php
if ( !defined( "IN_OP" ) )
{
    exit( "You can't access this file directly..." );
}
if ( ( $curruser['acl'] < 255 || $curruser['acl'] == 255 && $curruser['prev_id'] != 0 ) && !SubAccountRight( $curruser, 1 ) )
{
    diemsg( "你不是管理者！" );
}
$ui = new UI();
$tpl = new Template2();
$conf = new Config();
$rs = getdb( "select * from lotto where open>='".date( "Y-m-d" )."' order by open" );
if ( $rs->eof )
{
    $ui->showErrorPage( "<p class=error>目前没有可以下注期数！</p>" );
    exit();
}
$open = $rs->f['open'];
$round = $rs->f['round'];
$lotto_id = $rs->f['id'];
$opnumber = $rs->f['n1'];
$rs->close();
$stopbet = $conf->get( "linebet" );
$startmode = "";
if ( date( "Y-m-d" ) < $open )
{
    $startmode = "disabled";
}
else if ( date( "Y-m-d" ) == $open )
{
    if ( $stopbet <= date( "Hi" ) && 0 < $opnumber )
    {
        $startmode = "disabled";
    }
    else if ( date( "Hi" ) <= $conf->get( "startbet" ) )
    {
        $startmode = "disabled";
    }
}
$t1 = strtotime( $open." ".$stopbet );
$dt = date( "Y-m-d" );
$tpl->Set( "timestap", $t1 - systime( ) );
$tpl->set( "phptime", systime( ) );
$tpl->set( "open", $open );
$tpl->set( "round", d3( $round ) );
$tpl->set( "dt", $dt );
$tpl->set( "lotto_id", $lotto_id );
$rs48 = getdb( "select sum(amount*upercent/100) from bet where lotto_id=".$lotto_id." and bettype=48 and rame in (0,9)" );
$rs8 = getdb( "select sum(amount*upercent/100) from bet where lotto_id=".$lotto_id." and bettype=8 and rame in (0,9)" );
$rs7 = getdb( "select sum(amount*upercent/100) from bet where lotto_id=".$lotto_id." and bettype=7 and rame in (0,9)" );
$rs11 = getdb( "select sum(amount*upercent/100) from bet where lotto_id=".$lotto_id." and bettype=11 and rame in (0,9)" );
$rss8 = getdb( "select sum(amount*percent255/100) from bet2 where lotto_id=".$lotto_id." and bettype=48 and rame in (0,9)" );
$rss8 = getdb( "select sum(amount*percent255/100) from bet2 where lotto_id=".$lotto_id." and bettype=8 and rame in (0,9)" );
$rss7 = getdb( "select sum(amount*percent255/100) from bet2 where lotto_id=".$lotto_id." and bettype=7 and rame in (0,9)" );
$rss11 = getdb( "select sum(amount*percent255/100) from bet2 where lotto_id=".$lotto_id." and bettype=11 and rame in (0,9)" );
$rsu48 = getdb( "select sum(amount) from bet8 where lotto_id=".$lotto_id." and bettype=48 and rame in (0,9)" );
$rsu8 = getdb( "select sum(amount) from bet8 where lotto_id=".$lotto_id." and bettype=8 and rame in (0,9)" );
$rsu7 = getdb( "select sum(amount) from bet8 where lotto_id=".$lotto_id." and bettype=7 and rame in (0,9)" );
$rsu11 = getdb( "select sum(amount) from bet8 where lotto_id=".$lotto_id." and bettype=11 and rame in (0,9)" );
$rs = getdb( "select * from rate8 where lotto_id={$lotto_id} AND disk = 1 LIMIT 1" );
if ( $rs->eof )
{
    $ui->showErrorPage( "<p class=error>系统目前维护中(三全中无赔率)，请稍後！</p>" );
    exit();
}
else
{
    $rate8Arr = array();
    $i = 1;
    while ( $i < 50 )
    {
        $rate8Arr["r8_{$i}"] = intval( $rs->f["r".d2( $i )] );
        ++$i;
    }
    sort( $rate8Arr );
}
$rs->close();
$rs = getdb( "select * from rate9 where lotto_id={$lotto_id} AND disk = 1 LIMIT 1" );
if ( $rs->eof )
{
    $ui->showErrorPage( "<p class=error>系统目前维护中(四全中无赔率)，请稍後！</p>" );
    exit();
}
else
{
    $rate9Arr = array();
    $i = 1;
    while ( $i < 50 )
    {
        $rate9Arr["r9_{$i}"] = intval( $rs->f["r".d2( $i )] );
        ++$i;
    }
    sort( $rate9Arr );
}
$rs->close();
$tpl->set( array( "r8_hi" => sprintf( "%d", $rate8Arr[48] ), "r8_lo" => sprintf( "%d", $rate8Arr[0] ) ) );
$tpl->set( array( "r48_hi" => sprintf( "%d", $rate9Arr[48] ), "r48_lo" => sprintf( "%d", $rate9Arr[0] ) ) );
$rs = getdb( "select * from rate5a where lotto_id=".$lotto_id );
if ( $rs->eof )
{
    $ui->showErrorPage( "<p class=error>系统目前维护中，请稍後！</p>" );
    exit();
}
$tpl->set( "r9_1", $rs->f['r9_1'] );
$tpl->set( "r9_2", $rs->f['r9_2'] );
$tpl->set( "r7_1", $rs->f['r7_1'] );
$tpl->set( "r10_1", $rs->f['r10_1'] );
$tpl->set( "r10_2", $rs->f['r10_2'] );
$tpl->set( "r11_1", $rs->f['r11_1'] );
$b21a = isset( $_COOKIE['b21a'] ) ? $_COOKIE['b21a'] : "";
$tpl->set( "b21a", $b21a );
$b21b = isset( $_COOKIE['b21b'] ) ? $_COOKIE['b21b'] : "";
$tpl->set( "b21b", $b21b );
$b22 = isset( $_COOKIE['b22'] ) ? $_COOKIE['b22'] : "";
$tpl->set( "b22", $b22 );
$b23 = "";
$tpl->set( "b23", $b23 );
$tpl->set( "startnowdisable", $startmode );
$tpl->set( "money48", $rs48->f[0] + $rss48->f[0] - $rsu48->f[0] - 0 );
$tpl->set( "money08", $rs8->f[0] + $rss8->f[0] - $rsu8->f[0] - 0 );
$tpl->set( "money09", $rs9->f[0] + $rss9->f[0] - $rsu9->f[0] - 0 );
$tpl->set( "money07", $rs7->f[0] + $rss7->f[0] - $rsu7->f[0] - 0 );
$tpl->set( "money10", $rs10->f[0] + $rss10->f[0] - $rsu10->f[0] - 0 );
$tpl->set( "money11", $rs11->f[0] + $rss11->f[0] - $rsu11->f[0] - 0 );
$prot_user = array();
$j = 0;
$i = 0;
while ( $i < 10 )
{
    $name = $conf->get( "port_systemuser_".$i );
    if ( $name != "" )
    {
        $prot_user[$j] = $name;
        ++$j;
    }
    ++$i;
}
$userrame1 = "&nbsp;<select name=account style='display:none'><option value='' selected> </option>";
$i = 0;
while ( $i < $j )
{
    $userrame1 .= "<option value='".$prot_user[$i]."'>".$prot_user[$i]."</option>";
    ++$i;
}
$userrame1 .= "</select>";
$tpl->set( "select_usr1", $userrame1 );
include_once( "class_6h/class.menu.php" );
$fieldArr = array( "round" => $round, "open" => $open, "lotto_id" => $lotto_id, "split_id" => 1 );
$onlineMenu = new menu_6h( 2, $fieldArr );
$selectid = getvar( "select" ) == "" ? 0 : getvar( "select" );
$menuList = $onlineMenu->getMenu( $selectid );
$tpl->set( "menuList", $menuList );
$tpl->set( "selectid", $selectid );
unset( $onlineMenu );
$tpl->load( "main", "unow3.htm" );
$tpl->set( "jslang", $g_conf['language'] );
$tpl->show( "main" );
$ui->footer();
?>